/*
 * Copyright (c) 2024 Huawei Technologies Co., Ltd.
 * openUBMC is licensed under Mulan PSL v2.
 * You can use this software according to the terms and conditions of the Mulan PSL v2.
 * You may obtain a copy of Mulan PSL v2 at:
 *         http://license.coscl.org.cn/MulanPSL2
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
 * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
 * See the Mulan PSL v2 for more details.
 */

#include "i2c_mux.h"
#include <mc/log.h>

using namespace dev;

bool bus_i2c_mux::init(mc::mutable_dict& csr_object) {
    try {
        // 从字典中提取各个属性值并设置到对象中
        if (csr_object.contains("ChannelId")) {
            this->m_channel_id = csr_object["ChannelId"].as<uint8_t>();
        }
    } catch (const std::exception& e) {
        elog("I2C MUX bus initialization failed: ${exception}", ("exception", e.what()));
        return false;
    }

    return true;
}

uint8_t bus_i2c_mux::get_id() {
    return this->m_channel_id;
}

void bus_i2c_mux::bus_lock() {
    MC_THROW(mc::invalid_op_exception, "I2C MUX bus_lock not supported");
}

void bus_i2c_mux::bus_unlock() {
    MC_THROW(mc::invalid_op_exception, "I2C MUX bus_unlock not supported");
}

uint32_t bus_i2c_mux::read(ACCESS_DATA_S& data) {
    MC_THROW(mc::invalid_op_exception, "I2C MUX read not supported");
}

uint32_t bus_i2c_mux::write(ACCESS_DATA_S& data) {
    MC_THROW(mc::invalid_op_exception, "I2C MUX write not supported");
}